/**
 * All Rights Reserved , Copyright (C) 2023 , 青岛鼎信通讯股份有限公司
 *
 *BasePermissionManageHistoryController
 * 基础权限管理历史
 *
 * 修改纪录
 * 2023-03-30 版本：1.0 wangxinhua 创建。
 * @version 版本：1.0
 * @author 作者：wangxinhua
 * 创建日期：2023-03-30
 */

package com.topscomm.base.controller;

import java.util.List;
import java.util.Map;

import com.topscomm.base.pojo.BasePermissionManageEntity;
import com.topscomm.base.pojo.BasePermissionManageHistoryEntity;
import com.topscomm.pub.util.BaseUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topscomm.base.controller.auto.BasePermissionManageHistoryControllerAuto;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

/**
 * @author: wangxinhua
 * @date: 2023-03-30
 * @description:基础权限管理历史Controller
 * @modify:
 */
@RestController
@RequestMapping("base/permissionManageHistory")
public class BasePermissionManageHistoryController extends BasePermissionManageHistoryControllerAuto implements IBasePermissionManageHistoryController {
	/**
	 * @author: wangxinhua
	 * @date: 2023-03-30
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_sharetype")) {
			String value = paraMap.get("qry_sharetype").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and sharetype like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_shareobjectsdesc")) {
			String value = paraMap.get("qry_shareobjectsdesc").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and shareobjectsdesc = '{0}' ", value);
		}
		if (paraMap.containsKey("qry_sourcetype")) {
			String value = paraMap.get("qry_sourcetype").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and sourcetype = '{0}' ", value);
		}
		if (paraMap.containsKey("qry_sourceid")) {
			String value = paraMap.get("qry_sourceid").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and sourceid = '{0}' ", value);
		}
		if (paraMap.containsKey("qry_sourceflag")) {
			String value = paraMap.get("qry_sourceflag").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and sourceflag = '{0}' ", value);
		}
		if (paraMap.containsKey("qry_self")) {
			sql.appendSingle(" and sourceusercodes = '{0}' ", this.getUserBean().getUser().getCode());
		}
		return sql.toString();
	}

	/**
	 * @author: wangxinhua
	 * @date: 2023-03-30
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}

	/**
	 * @description:查询已有人员
	 * @param paraMap
	 * @return
	 * @author: zhanglongfei
	 * @date: 2020年11月3日上午9:48:36
	 * @modify:
	 */
	@GetMapping(value = "/queryList")
	public ResponseResult<Object> queryList(@RequestParam(required = false) Map<String, Object> paraMap) {
		try {
			paraMap = BaseUtil.decodeSecureMap(paraMap);
			String sqlWhere = this.spellListSql(paraMap);
			List<BasePermissionManageHistoryEntity> list = this.service.queryByWhere(sqlWhere);
			return ResponseResult.ok(list);
		} catch (Exception e) {
			return handleControllerException(e);
		}
	}
}

